//
//  XJ_ChangeBandsView.m
//  XunJieProject
//
//  Created by xue on 2018/6/12.
//  Copyright © 2018年 Soowin. All rights reserved.
//

#import "XJ_ChangeBandsView.h"
#import "XJ_SelectBandCell.h"

@implementation XJ_ChangeBandsView
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code

    self.backgroundColor =[UIColor colorWithWhite:0 alpha:0.5];
    self.bottomView.layer.cornerRadius =5;
    self.bottomView.layer.masksToBounds =YES;
    
    self.myTableView.delegate =self;
    self.myTableView.dataSource =self;
    self.myTableView.backgroundColor =RGBCOLOR(245, 246, 247);
    
    
}

+ (instancetype)changeBandsView{
    NSString *className = NSStringFromClass([self class]);
    UINib *nib = [UINib nibWithNibName:className bundle:nil];
    return [nib instantiateWithOwner:nil options:nil].firstObject;
    
}

- (IBAction)Click_btn:(id)sender {
    
    if (self.block) {
        self.block(3,YES);
    }
    self.hidden =YES;

}

-(void)refreshTableView:(NSMutableArray*)array{
    
    if (self.dataArray.count>0) {
        [self.dataArray removeAllObjects];
    }
    [self.dataArray addObjectsFromArray:array];
    [self.myTableView reloadData];
}
#pragma mark--UITableViewDelegate,UITableViewDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 2;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * identifier = @"cell";
    XJ_SelectBandCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    
    if (cell == nil) {
        
        cell =[[[NSBundle mainBundle] loadNibNamed:@"XJ_SelectBandCell" owner:nil options:nil]firstObject];
        cell.selectionStyle =UITableViewCellSelectionStyleNone;
        cell.backgroundColor =[UIColor clearColor];
    }
    return cell;
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.01;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (self.block) {
        self.block(indexPath.row,NO);
    }
    self.hidden =YES;
    

}
-(NSMutableArray*)dataArray{
    
    if (!_dataArray) {
        _dataArray =[[NSMutableArray alloc]init];
    }
    return _dataArray;
}
@end
